﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.ComponentModel.Design;

namespace DesignPanel
{
    [ToolboxBitmap(typeof(UserControl))]
    public partial class FormDesigner : UserControl
    {
        private DesignSurfaceEx m_theDesignSurface = null;

        public FormDesigner()
        {
            InitializeComponent();
        }

        public void InitSurface(DesignType type)
        {
            m_theDesignSurface = new DesignSurfaceEx();
            switch (type)
            {
                case DesignType.Form:
                    m_theDesignSurface.BeginLoad(typeof(Form));
                    break;
                case DesignType.Control:
                    m_theDesignSurface.BeginLoad(typeof(UserControl));
                    break;
                default:
                    return;
            }
            if (m_theDesignSurface.DesignContainer != null)
            {
                m_theDesignSurface.DesignContainer.Dock = DockStyle.Fill;
                this.Controls.Add(m_theDesignSurface.DesignContainer);
            }
        }

        public DesignSurfaceEx Surface
        {
            get
            {
                return m_theDesignSurface;
            }
        }

        public enum DesignType
        {
            Form = 0,
            Control
        }
    }
}
